<template>
  <div>
    <div>
      <ele-page
        v-loading="loading"
        :formConfig="searchDialog"
        ref="eleTable"
        :operateList="operateList"
        @handleOperateEvent="handleOperateEvent"
        :column="column"
        :getList="mesKtStockInfoPageL"
        uniqueId="mesKtStockInfoTableL"
      ></ele-page>
    </div>
  </div>
</template>

<script>
import { operateList, searchConfig, formDescDialogMixin, rowConfig } from './config'

import { mixinDialog } from '@/views/materials/tmMaterialList/ele-dialog-table/mixin'
import {repairItemCreate, repairItemDeleteById, repairItemPage, repairItemUpdate} from "@/api/repair/item";
import {getDict} from "@/api/common";
import dialogRepairTable from '@/views/materials/tmMaterialList/ele-dialog-table/index'
import {mesKtStockInfoPageL} from "@/api/mesKtStockInfo/mesKtStockInfo";
import {getCurrentWarehouseCode} from "@/api/inbound/mesInTask";
export default {
  name: 'repairItem',
  components: { dialogRepairTable },
  mixins: [ formDescDialogMixin, searchConfig,mixinDialog],
  data() {
    const self = this
    return {
      title: null,
      visible: false,
      isLoading: false,
      loading: false,

      formDataDialog: {},
      // formDescDialog, //新增修改框
      operateList,
      mesKtStockInfoPageL,
      // 列表页字段的绑定配置
      column: [
        {
          type: 'selection',
          fixed: 'left'
        },
        {
          type: 'index',
          label: $i18n.t('common.order'),
          width: 60,
          fixed: 'left'
        },
        {
          prop: "warehouseCode",
          columnKey: "warehouseName",
          label: $i18n.t("common.warehouseName"),
          fixed: "left",
          width: 150,
          optionProp: {
            value: "modelingCode",
            label: "modelingName",
          },
          option: async (data) => {
            const res = await getCurrentWarehouseCode();
            let list = res.data.result || []
            list.forEach(val => {
              val.modelingName = `${val.modelingCode}-${val.modelingName}`
            });
            return list;
          },
        },
        {
          prop: 'itemName',
          label: '物料名称',
          showOverflowTooltip: true
        },
        {
          prop: 'itemCode',
          label: '物料编号',
          showOverflowTooltip: true
        },
        {
          prop: 'itemBrand',
          label: '品牌',
          showOverflowTooltip: true
        },
        {
          prop: 'itemUnit',
          label: '规格',
          showOverflowTooltip: true
        },
        {
          prop: 'itemNum',
          label: '物料总量',
        },
        {
          prop: 'materialUnit',
          label: '物料单位',
        },
        {
          prop: 'itemPackCount',
          label: '包装数',
        },
        {
          prop: 'itemPackUnit',
          label: '包装单位',
        },
        {
          prop: 'itemVin',
          label: 'VIN关联',
          showOverflowTooltip: true
        },
        {
          prop: 'mark',
          label: '备注',
          showOverflowTooltip: true
        },
        // {
        //   prop: 'operate',
        //   label: $i18n.t('common.operation'),
        //   width: 160,
        //   fixed: 'right',
        //   render: (h, scope) => {
        //     return <ele-row-operation scope={scope} rowConfig={rowConfig} onRowOperate={this.rowOperate} />
        //   }
        // }
      ]
    }
  },
  computed: {},
  methods: {
    // 表格顶部按钮操作事件
    handleOperateEvent(data) {
      this.title = data.name
      const fnc = {
        // add: () => {
        //   this.formDataDialog = {}
        //   this.visible = true
        // },
        // deleteBatch: () => {
        //   this.$confirm('此操作将删除所选数据及关联明细数据, 是否继续?', $i18n.t('common.tip'), {
        //     confirmButtonText: $i18n.t('common.ok'),
        //     cancelButtonText: $i18n.t('common.cancel'),
        //     type: 'warning'
        //   }).then(() => {
        //     const ids = data.rows.map((val) => val.id).join(',')
        //     this.rowDel(ids)
        //   })
        // },
      }
      fnc[data.handleName]()
    },
    // 表格行操作事件
    rowOperate({ handleName, name, row }) {
      this.title = name
      const fnc = {
        // edit: () => {
        //   this.formDataDialog = { ...row }
        //   this.visible = true
        // },
        // delete: () => {
        //   this.$confirm('此操作将删除所选数据及关联明细数据, 是否继续?', $i18n.t('common.tip'), {
        //     confirmButtonText: $i18n.t('common.ok'),
        //     cancelButtonText: $i18n.t('common.cancel'),
        //     type: 'warning'
        //   }).then(() => {
        //     this.rowDel(row.id)
        //   })
        // }
      }
      fnc[handleName]()
    },
    // 刷新表格数据
    refresh(isReset = true) {
      this.$refs.eleTable.refresh(isReset)
    }
  }
}
</script>
